package com.ziyueyuwen.xiniao.service.baseservice.report.impl;

import com.ziyueyuwen.xiniao.bean.ZyClassInfo;
import com.ziyueyuwen.xiniao.bean.ZyClassLessonTransfer;
import com.ziyueyuwen.xiniao.bean.report.StudentLessonReportVO;
import com.ziyueyuwen.xiniao.bean.report.ZyStudentLessonReport;
import com.ziyueyuwen.xiniao.bean.vo.ZyLessonVO;
import com.ziyueyuwen.xiniao.dao.ZyStudentLessonReportMapper;
import com.ziyueyuwen.xiniao.service.ClassService;
import com.ziyueyuwen.xiniao.service.LessonService;
import com.ziyueyuwen.xiniao.service.TransferStudentService;
import com.ziyueyuwen.xiniao.service.baseservice.report.ReportBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by wancheng on 2019/3/15.
 */
@Service
public class ReportBaseServiceImpl implements ReportBaseService {

    @Autowired
    ZyStudentLessonReportMapper zyStudentLessonReportMapper;

    @Override
    public Boolean save(ZyStudentLessonReport report) {
        return  returnRes(zyStudentLessonReportMapper.insertSelective(report));
    }

    @Override
    public ZyStudentLessonReport saveReturnPreKey(ZyStudentLessonReport report) {
        zyStudentLessonReportMapper.insertUseGeneratedKeys(report);
        return report;
    }

    @Override
    public void saveBatch(List<ZyStudentLessonReport> reports) {
        zyStudentLessonReportMapper.insertList(reports);
    }



    @Override
    public Boolean deleteByPreKey(Integer id) {
        return returnRes(zyStudentLessonReportMapper.deleteByPrimaryKey(id));
    }

    @Override
    public Boolean delete(ZyStudentLessonReport report) {
        return returnRes(zyStudentLessonReportMapper.delete(report));
    }

    @Override
    public Boolean updateByPreKey(ZyStudentLessonReport report) {
        return returnRes(zyStudentLessonReportMapper.updateByPrimaryKeySelective(report));
    }

    @Override
    public ZyStudentLessonReport getByPreKey(Integer id) {
        return zyStudentLessonReportMapper.selectByPrimaryKey(id);
    }

    @Override
    public ZyStudentLessonReport getOne(ZyStudentLessonReport report) {
        return zyStudentLessonReportMapper.selectOne(report);
    }

    @Override
    public List<ZyStudentLessonReport> getByReport(ZyStudentLessonReport param) {
        return zyStudentLessonReportMapper.select(param);
    }

    @Override
    public List<ZyStudentLessonReport> getAll() {
        return zyStudentLessonReportMapper.selectAll();
    }

    @Override
    public ZyStudentLessonReport getByReport(String studentAccount, Integer lessonId) {
        ZyStudentLessonReport param = new ZyStudentLessonReport();
        param.setStudentAccount(studentAccount);
        param.setLessonId(lessonId);
        return getOne(param);
    }

    @Override
    public List<StudentLessonReportVO> getStudentLessonReport(Integer classId,Integer lessonIndex) {
        return zyStudentLessonReportMapper.getStudentLessonReport(classId,lessonIndex);
    }

    @Override
    public List<StudentLessonReportVO> getStudentLessonReport(Integer lessonId) {
        return zyStudentLessonReportMapper.getStudentLessonReportByLessonId(lessonId);
    }
}
